---
slug: 模块化 #路径，不能重复
title: 模块化 # 标题
authors: [] # 作者，在authors.yml配置
tags: [facebook, hello, docusaurus] # 标签，在tags.yml配置
toc_min_heading_level: 2 # 最小展示标题
toc_max_heading_level: 5 # 最大展示标题
---

##### webpack如何支持module.export和import的

```js
 (() => {
 	var __webpack_modules__ = ({

 "./src/dateformat/index.js":
 ((module) => {

const getDate = ()=> new Date();

const dateFormatter = date=>new Intl.DateTimeFormat("zh-cn")
    .format(date)
    .replaceAll('/','-')

module.exports = {
    getDate,dateFormatter
}

 }),

 "./src/math/index.js":
 ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
 __webpack_require__.d(__webpack_exports__, {
   multiply: () => (/* binding */ multiply),
   sum: () => (/* binding */ sum)
 });
const sum = (a, b) => a + b;

const multiply = (a, b) => a * b;

 })

 	});
 	var __webpack_module_cache__ = {};
 	function __webpack_require__(moduleId) {
 		var cachedModule = __webpack_module_cache__[moduleId];
 		if (cachedModule !== undefined) {
 			return cachedModule.exports;
 		}
 		var module = __webpack_module_cache__[moduleId] = {
 			exports: {}
 		};
 	
 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
 	
 		return module.exports;
 	}
 	
 	(() => {
 		__webpack_require__.d = (exports, definition) => {
 			for(var key in definition) {
 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
 				}
 			}
 		};
 	})();
 	
 	(() => {
 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
 	})();
 	
 	(() => {
 		__webpack_require__.r = (exports) => {
 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
 			}
 			Object.defineProperty(exports, '__esModule', { value: true });
 		};
 	})();
var __webpack_exports__ = {};
(() => {
"use strict";
__webpack_require__.r(__webpack_exports__);
var _math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math */ "./src/math/index.js");

const {dateFormatter}  = __webpack_require__(/*! ./dateformat/index */ "./src/dateformat/index.js");
console.log((0,_math__WEBPACK_IMPORTED_MODULE_0__.sum)(1, 2));

console.log(dateFormatter(new Date()));
})();

 })()
;

```